home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / UDDIWEB.MSI / error.aspx20 < prev    next >
Encoding:
ASP.NET Web Form  |  2003-02-21  |  8.8 KB  |  331 lines

  1. <%@ Page Language='C#' Inherits='UDDI.Web.UddiPage' %>
  2. <%@ Register TagPrefix='uddi' Namespace='UDDI.Web' Assembly='uddi.web' %>
  3. <%@ Register Tagprefix='uddi' Tagname='Header' Src='controls/header.ascx' %>
  4. <%@ Register Tagprefix='uddi' Tagname='Footer' Src='controls/footer.ascx' %>
  5. <%@ Register Tagprefix='uddi' Tagname='BreadCrumb' Src='controls/breadcrumb.ascx' %>
  6. <%@ Import Namespace='System.Data.SqlClient' %>
  7. <%@ Import Namespace='UDDI' %>
  8.  
  9. <script language='C#' runat='server'>
  10.     protected bool allowRetry = false;
  11.     protected bool frames;    
  12.     protected string root;
  13.  
  14.     void Page_Init( object source, EventArgs eventArgs )
  15.     {
  16.         
  17.         try
  18.         {
  19.         frames = ( "true" == Request[ "frames" ] );
  20.         
  21.         root = ( "/" == Request.ApplicationPath ) ? "" : Request.ApplicationPath;
  22.         
  23.         
  24.         string html = "";
  25.         
  26.         //
  27.         // Grab the exception from the current context, then clear
  28.         // the error so ASP.NET won't try to throw it's own error
  29.         // page.
  30.         //
  31.         Exception e = (Exception)Session[ "exception" ];
  32.         
  33.         if( null == e )
  34.         {
  35.             e = new UDDIException(
  36.                 ErrorType.E_fatalError,
  37.                 "UDDI_ERROR_FATALERROR_UNKNOWN" );            
  38.         }
  39.         else if( null != e.InnerException )
  40.         {
  41.             if( e.InnerException is SqlException && ((SqlException)e.InnerException).Number >= 50000 )
  42.             {
  43.                 SqlException se = (SqlException)e.InnerException;
  44.                 
  45.                 e = new UDDIException(
  46.                         (ErrorType)( se.Number - 50000 ),
  47.                         "UDDI_ERROR_SQL_EXCEPTION", 
  48.                         se.Message 
  49.                     );                    
  50.             }
  51.             else if( e.InnerException is UDDIException )
  52.                 e = e.InnerException;
  53.         }
  54.         
  55.         //
  56.         // Determine whether we should be showing the stack.
  57.         // SECURITY: Should we be doing a Debug.VerifySetting on Debug.StackTrace?
  58.         //
  59.         bool showStack = false;    
  60.         
  61.         try
  62.         {
  63.             if( 1 == Config.GetInt( "Debug.StackTrace", UDDI.Constants.Debug.StackTrace ) )
  64.                 showStack = true;
  65.         }
  66.         catch( Exception )
  67.         {
  68.         }
  69.  
  70.         //
  71.         // Try to provide more detailed information on the source of the
  72.         // exception.  If we don't know the exception type, we'll simply
  73.         // output the exception message.
  74.         //        
  75.         if( e is UDDIException )
  76.         {
  77.             UDDIException ue = (UDDIException)e;
  78.             
  79.             html += 
  80.                 "<b>" + 
  81.                 String.Format( 
  82.                     Localization.GetString( "TAG_ERROR" ), 
  83.                     "</b>" + ue.Number.ToString() + " (" + (int)ue.Number + ")<b>" ) + 
  84.                 "</b><br><br>" ;
  85.                 
  86.             breadcrumb.AddBlurb( ue.Number.ToString() + " (" + (int)ue.Number + ")", null, null, null, false );
  87.         
  88.                
  89.             switch( ue.Number )
  90.             {
  91.                 case ErrorType.E_accountLimitExceeded:
  92.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_ACCOUNT_LIMIT_EXCEEDED" ) + "</p>";                
  93.                     break;
  94.                 
  95.                 case ErrorType.E_busy:
  96.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_BUSY" ) + "</p>";
  97.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_CONTACT_SYSTEM_ADMINISTRATOR" ) + "</p>";                
  98.                     
  99.                     allowRetry = true;
  100.                     break;
  101.                 
  102.                 case ErrorType.E_categorizationNotAllowed:
  103.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_CATEGORIZATION_NOT_ALLOWED" ) + "</p>";                
  104.                     break;
  105.                 
  106.                 case ErrorType.E_fatalError:
  107.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_FATAL_ERROR" ) + "</p>";
  108.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_CONTACT_SYSTEM_ADMINISTRATOR" ) + "</p>";                                
  109.                     
  110.                     allowRetry = true;
  111.                     break;
  112.  
  113.                 case ErrorType.E_invalidKeyPassed:
  114.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_INVALID_KEY_PASSED" ) + "</p>";                
  115.                     break;
  116.  
  117.                 case ErrorType.E_invalidCategory:
  118.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_INVALID_CATEGORY" ) + "</p>";                
  119.                     break;
  120.  
  121.                 case ErrorType.E_keyRetired:
  122.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_KEY_RETIRED" ) + "</p>";                
  123.                     break;
  124.                     
  125.                 case ErrorType.E_languageError:
  126.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_LANGUAGE_ERROR" ) + "</p>";                
  127.                     break;
  128.  
  129.                 case ErrorType.E_nameTooLong:
  130.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_NAME_TOO_LONG" ) + "</p>";                
  131.                     break;
  132.  
  133.                 case ErrorType.E_operatorMismatch:
  134.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_OPERATOR_MISMATCH" ) + "</p>";                
  135.                     break;
  136.  
  137.                 case ErrorType.E_userMismatch:
  138.                     html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_USER_MISMATCH" ) + "</p>";                
  139.                     break;
  140.                                     
  141.                 default:
  142.                     break;
  143.             }
  144.         }
  145.         else if( null != e )
  146.         {
  147.             html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_FATAL_ERROR" ) + "</p>";
  148.             html += "<p style='width: 400px'>" + Localization.GetString( "ERROR_CONTACT_SYSTEM_ADMINISTRATOR" ) + "</p>";                                
  149.         }
  150.         
  151.         //
  152.         // BUG: 2351
  153.         //
  154.         html += GetFormatedErrorString( e, showStack );
  155.         
  156.         
  157.         //
  158.         // BUG: 2351
  159.         //    Removed the following code and replaced it with logic to display
  160.         //    dynamicly visible error strings.
  161.         //
  162.         /*
  163.         // Display a stack trace, if requested.
  164.         //
  165.         if( null != e && showStack )
  166.         {
  167.           string trace = e.ToString();
  168.           
  169.           trace = trace.Replace( "\r\n", "<br>" );
  170.           trace = trace.Replace( "  ", "  " );
  171.           
  172.           html += "<p><b>" + Localization.GetString( "TAG_STACK_TRACE" ) + "</b><br>" + trace + "</p>";
  173.         }
  174.         */
  175.         
  176.         errText.Text = html;
  177.         
  178.         retry.Visible = allowRetry;
  179.  
  180.         }
  181.         catch( Exception e )
  182.         {
  183.             errText.Text = "<p style='width: 400px'>" + Localization.GetString( "ERROR_FATAL_ERROR" ) + "</p>";
  184.             errText.Text += "<p style='width: 400px'>" + Localization.GetString( "ERROR_CONTACT_SYSTEM_ADMINISTRATOR" ) + "</p>";
  185.         }
  186.     }
  187.     
  188.     private string GetFormatedErrorString( Exception e, bool showstack )
  189.     {
  190.         string s = "";
  191.  
  192.             
  193.  
  194.         if( null != e )
  195.         {    
  196.             string msg = "";
  197.             if( e is UDDIException )
  198.                 msg = ( (UDDIException) e ).GetMessage( UDDITextContext.UI );
  199.             else
  200.                 msg = e.Message;
  201.  
  202.             s += "<p><a onclick='expandError()' style='cursor:hand;font-weight:bold;'>"+Localization.GetString( "TAB_DETAILS" )+"</a><br>";
  203.             
  204.             if( showstack )
  205.             {
  206.                 s += "<div id='ErrorDetails' class='boxed'><b>" + Localization.GetString( "TAG_STACK_TRACE" ) + "</b><br><span >" + e.ToString().Replace( "\n","<br>" ).Replace( "  ", "  " ) + "</span></div>";
  207.             }
  208.             else
  209.             {
  210.                 s += "<div id='ErrorDetails' class='boxed'><span >" + msg +"</span></div>";    
  211.             }
  212.             s+= "</p>";
  213.             
  214.         }
  215.         return s;
  216.     }
  217. </script>
  218. <uddi:StyleSheetControl
  219.     Runat='server'
  220.     Default='../stylesheets/uddi.css' 
  221.     Downlevel='../stylesheets/uddidl.css' 
  222.     />
  223. <uddi:PageStyleControl 
  224.     Runat='server'
  225.     OnClientContextMenu='Document_OnContextMenu()'
  226.     />
  227. <uddi:ClientScriptRegister
  228.     Runat='server'
  229.     Source='../client.js'
  230.     Language='javascript'
  231.     />
  232. <uddi:SecurityControl 
  233.     Runat='server' 
  234.     />
  235. <form enctype='multipart/form-data' Runat='server'>
  236. <script>
  237.     function expandError( )
  238.     {
  239.         var elt = GetElementById( "ErrorDetails" );
  240.     
  241.         if( document.getElementById )
  242.         {
  243.             //
  244.             // Render IE5+
  245.             //
  246.             if( elt.style.display == "none" )
  247.                 elt.style.display = "block";
  248.             else
  249.                 elt.style.display = "none";
  250.         }
  251.         else if( document.all )
  252.         {
  253.             //
  254.             // Render IE4
  255.             //
  256.             if( elt.style.display == "none" )
  257.                 elt.style.display = "block";
  258.             else
  259.                 elt.style.display = "none";
  260.         }
  261.         else if( document.layers )
  262.         {
  263.             //
  264.             // Render NS 4+
  265.             //
  266.             if( elt.style.visiblity == "hidden" )
  267.                 elt.style.visiblity = "visible";
  268.             else
  269.                 elt.style.visibility = "hidden";
  270.         }
  271.         else
  272.         {
  273.             //
  274.             // Unsupported Browser Type.
  275.             //
  276.                     
  277.         }
  278.     }
  279.  
  280.  
  281. </script>
  282. <table width='100%' border='0' height='100%' cellpadding='0' cellspacing='0' >
  283.         <asp:PlaceHolder
  284.             Id='HeaderBag'
  285.             Runat='server'
  286.             >
  287.             <tr height='95'>
  288.                 <td>
  289.                     <!-- Header Control Here -->
  290.                     <uddi:Header
  291.                         Runat='server' 
  292.                         />
  293.                 </td>
  294.             </tr>
  295.         </asp:PlaceHolder>
  296.         <tr height='100%' valign='top'>
  297.             <td>
  298.                 <uddi:BreadCrumb 
  299.                     Id='breadcrumb' 
  300.                     Runat='server' 
  301.                     />
  302.                 <table cellpadding='0' cellspacing='0' width='100%' border='0' style='table-layout: fixed' class='helpBlock'>
  303.                     <tr>
  304.                         <td colspan='2' style='padding: 15px'>
  305.                             <h1><uddi:StringResource Name='HEADING_ERROR_PROCESSING_REQUEST' Runat='server' /></h1>
  306.                             <asp:Label ID='errText' CssClass='normal' Runat='server' />
  307.                             <script>/*Close the error on load.*/expandError();</script>
  308.                             <asp:PlaceHolder ID='retry' Runat='server'>
  309.                                 <!-- Removed Retry Feature. -->
  310.                             </asp:PlaceHolder>
  311.                         </td>
  312.                     </tr>
  313.                 </table>
  314.             </td>
  315.         </tr>
  316.         <asp:PlaceHolder 
  317.             Id='FooterBag'
  318.             Runat='server'
  319.             >
  320.             <tr height='95'>
  321.                 <td>
  322.                     <!-- Footer Control Here -->
  323.                     <uddi:Footer
  324.                         Runat='server' 
  325.                         />
  326.                 </td>
  327.             </tr>
  328.         </asp:PlaceHolder>
  329.     </table> 
  330. </form>
  331.